from pydantic_settings import BaseSettings
from pydantic import Field
from typing import List
from video_agent.config import (
    MODEL_NAME, MODEL_TIMEOUT, API_BASE_URL, API_KEY,
    MAX_RETRIES, RETRY_DELAY, MAX_VIDEO_SIZE
)

class Settings(BaseSettings):
    """应用配置类"""
    # 基础配置
    UPLOAD_DIR: str = "uploads"
    MAX_FILE_SIZE: int = MAX_VIDEO_SIZE
    
    # 允许的文件类型
    ALLOWED_MIME_TYPES: List[str] = [
        'video/mp4', 
        'video/webm',
        'video/webm;codecs=h264',
        'video/webm;codecs=vp8',
        'video/quicktime', 
        'video/x-msvideo',
        'video/x-matroska'
    ]
    ALLOWED_EXTENSIONS: List[str] = ['.mp4', '.webm', '.mov', '.avi']
    
    # 速率限制配置
    RATE_LIMIT: int = 10  # 每分钟请求数限制
    RATE_WINDOW: int = 60  # 时间窗口（秒）
    
    # 服务器配置
    DEFAULT_PORT: int = 8000
    HOST: str = "0.0.0.0"
    
    # 日志配置
    LOG_FORMAT: str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    LOG_LEVEL: str = 'DEBUG'
    
    # 模型配置
    MODEL_NAME: str = MODEL_NAME
    MODEL_TIMEOUT: int = MODEL_TIMEOUT
    API_BASE_URL: str = API_BASE_URL
    API_KEY: str = API_KEY
    
    # 重试配置
    MAX_RETRIES: int = MAX_RETRIES
    RETRY_DELAY: int = RETRY_DELAY
    
    class Config:
        case_sensitive = True

# 创建全局配置实例
settings = Settings() 